﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace MessengerBot
{
    /// <summary>
    /// This interface must be implemented by classes that implement bot sub-systems,
    /// that expose a command line interface to the user.
    /// </summary>
    public interface ISystem
    {
        /// <summary>
        /// This method is called when a session is started between the bot and a user.
        /// </summary>
        /// <param name="bot">
        /// The <see cref="Bot"/> instance that manages the <paramref name="session"/>.
        /// </param>
        /// <param name="session">
        /// The <see cref="Session"/> that was started.
        /// </param>
        /// <returns>
        /// Returns a state object that the systemwants to keep while the session is alive,
        /// which will be passed as the state argument to other methods on the
        /// <see cref="ISystem"/> interface.
        /// </returns>
        object SessionStarted(Bot bot, Session session);

        /// <summary>
        /// This method is called when a session ends.
        /// </summary>
        /// <param name="bot">
        /// The <see cref="Bot"/> instance that managed the <paramref name="session"/>.
        /// </param>
        /// <param name="session">
        /// The <see cref="Session"/> that ended.
        /// </param>
        /// <param name="state">
        /// The state object that was originally obtained through <see cref="SessionStarted"/>.
        /// </param>
        void SessionEnded(Bot bot, Session session, object state);

        /// <summary>
        /// This method is called when a message is received from the user.
        /// </summary>
        /// <param name="bot">
        /// The <see cref="Bot"/> instance that manages the <paramref name="session"/>.
        /// </param>
        /// <param name="session">
        /// The <see cref="Session"/> that was started.
        /// </param>
        /// <param name="state">
        /// The state object that was originally obtained through <see cref="SessionStarted"/>.
        /// </param>
        /// <param name="message">
        /// The message that was received.
        /// </param>
        void MessageReceived(Bot bot, Session session, object state, string message);
    }
}